/******************** 
	作用:选择地区
	作者:蔡俊雄
	版本:V1.0
	时间:2015-08-21
********************/

$(function() {
	//-----------------初始化选择框-----------------
	//	var demo1 = $('#multiSelect').bootstrapDualListbox({infoTextFiltered: '<span class="label label-purple label-lg">Filtered</span>'});
	//				var container1 = demo1.bootstrapDualListbox('getContainer');
	//				container1.find('.btn').addClass('btn-white btn-info btn-bold');
	var selectArray = [];
	if (parent.getAreaIds) {
		selectArray = parent.getAreaIds();
		$("#duallist option").each(function(index) {
			var value=$(this).val();
			if(General.indexOf(selectArray,value)!=-1){
//				$(this).attr("selected","selected");
				$(this).remove();
			}
		});
	}
	
	var dualList = $('#duallist').bootstrapDualListbox({
		infoTextFiltered: '<span class="label label-purple label-lg">查找结果</span>'
	});
	var container1 = dualList.bootstrapDualListbox('getContainer');
	container1.find('.btn').addClass('btn-white btn-info btn-bold');

	//-----------------确定-----------------
	//点击"确定"按钮
	$("#sure").on("click", function(e) {
		General.stopEvent(e);
		//获取已选中的数据
		var id="bootstrap-duallistbox-selected-list_duallist";
		var areaData=[];
		$("#"+id+" option").each(function(index) {
			var value=$(this).val();
			var area=$(this).html();
			areaData.push({
				"text":area,
				"value":value
			});
		});
		if(parent.selectArea){
			parent.selectArea(areaData);
		}
	});


});